{include file="common/mini-header" title="用户"}
<div class="layui-body">
	<!-- 内容主体区域 -->

	<form class="layui-form" action="" style="max-width: 800px;width: 90%;">	
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="text" name="username" value="{$userInfo['username']}" {if condition="$userInfo['username'] eq 'sysadmin'"} readonly title="超级管理员不能修改" {/if} required lay-verify="required" placeholder="用户名长度3~30" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">密码</label>
			<div class="layui-input-block">
				<input type="password" name="password" placeholder="密码留空不编辑" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">角色组</label>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="role_ids" lay-verify="required" {if condition="$userInfo['username'] eq 'sysadmin'"} disabled title="超级管理员不能修改"{/if}> 
					{:buildRoleSelect(0,'',$userInfo['role_ids'])}
				</select>
			</div>
		</div>	
		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-block">
				{volist name="statusList" id="value" }
				{if condition="$userInfo['status'] eq $key"}
				<input type="radio" name="status" value="{$key}" title="{$value}" checked=""  />
				{else /}
				<input type="radio" name="status" value="{$key}" title="{$value}"  {if condition="$userInfo['username'] eq 'sysadmin'"} disabled title="超级管理员不能修改"{/if}/>
				{/if}
				{/volist}
			</div>
		  </div>	 
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input type="hidden" name="id" value="{$userInfo['id']}">
				<button class="layui-btn" lay-submit lay-filter="editBtn">编辑</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

</div>
<script>
	layui.use('form', function() {
		var form = layui.form;
		var $ = layui.jquery;
		var layer = layui.layer;

		//监听提交
		form.on('submit(editBtn)', function(data) {
			$.post('./edit', data.field, function(rs) {
				if (rs.code == 1) {
					parent.location.reload();
				} else {
					layer.alert(rs.msg)
				}
			})
			return false;
		});
	});
</script>

{include file="common/footer"}